﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace FSC.HaNamAPApplication
{
    public partial class HNAP_Control_HomeNewAP : System.Web.UI.UserControl
    {
        public string CurrentUrlWithoutParam
        {
            get
            {
                return Controler.UrlWithoutParam(Request.RawUrl);
            }
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            HaNamAPDataDataContext db = new HaNamAPDataDataContext(Controler.HaNamAPConnectionString);

            var data = (from a in db.AdminProcedures
                        orderby a.AP_ID descending
                        select new
                        {
                            ID = a.AP_ID,
                            Title = a.Name,
                            Name = (a.Name.Length > 45) ? (a.Name.Substring(0, 48) + "...") : a.Name 
                        }).Take(7);
            rptAP.DataSource = data;
            rptAP.DataBind();
        }
    }
}